home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / block.cc < prev    next >
C/C++ Source or Header  |  1995-03-30  |  1KB  |  86 lines

  1. /*    Copyright Alex Hornby 1994/1995. All rights reserved.
  2.      See file README for details
  3. */
  4.  
  5. /* C++ code for block copy wrapper */
  6.  
  7. #include "screen.h"
  8. #include "asmblock.h"
  9. #include "block.h"
  10. #include <string.h>
  11.  
  12. #include "btypes.h"
  13.  
  14. Block::Block() : Screen()
  15. {
  16.     blockmem=0;
  17. }
  18.  
  19. Block::Block(const Block& b) : Screen(b)
  20. {
  21.     copy(b);
  22. }
  23.  
  24. Block::~Block()
  25. {
  26.     if(blockmem!=0)
  27.         delete [] blockmem;
  28. }
  29.  
  30. Block&
  31. Block::operator=(const Block& b)
  32. {
  33.     if(&b!=this)
  34.     {
  35.         Screen::operator=(b);
  36.         copy(b);
  37.     }
  38.     return *this;
  39. }
  40.  
  41. void
  42. Block::copy(const Block& b)
  43. {
  44.     width=b.width;
  45.     height=b.height;
  46.     byteLength=b.byteLength;
  47.     if(blockmem!=0)
  48.         delete [] blockmem;
  49.     if(b.blockmem!=0)
  50.     {
  51.         blockmem= new byte [byteLength];
  52.         memcpy(blockmem, b.blockmem, byteLength);
  53.     }
  54. }
  55.  
  56. void 
  57. Block :: cut ( uint32 x1, uint32 y1, uint32 xw, uint32 yw)
  58. {
  59.     width=xw;
  60.     height=yw;
  61.  
  62.     /* if memory in use then free it */
  63.     if( blockmem!=0 ) delete blockmem; 
  64.  
  65.     /* reserve block memory */
  66.     byteLength=xw*yw;
  67.     blockmem=new byte [byteLength];
  68.  
  69.     /* call assembly routine */
  70.     cutblock( getGraphMem()+x1+(y1*getScreenWidth()), blockmem, width, height); 
  71. }
  72.  
  73. void
  74. Block :: reCut( uint32 x1, uint32 y1)
  75. {
  76.     /* call assembly routine */
  77.     cutblock( getGraphMem()+x1+(y1*getScreenWidth()), blockmem, width, height); 
  78. }
  79.  
  80. void
  81. Block :: paste( uint32 x1, uint32 y1)
  82. {
  83.     /* Straight into the assembly bit */
  84.     pasteblock( blockmem, getGraphMem()+x1+(y1*getScreenWidth()), width, height );
  85. }
  86.